<?php

require_once LIBRARIES_TOOLS_UTILITY;
require_once LIBRARIES_TOOLS_XTEMPLATE;

class HeaderController {

    public function invoke() {

        // directory path
        $dir = dirname(__FILE__);

        $xtemplate = new XTemplate($dir . '/views/header.html');

        $groupFunctions = $_SESSION['groupFunctions'];


        if (Utility::checkPermission('view', $groupFunctions, ARTICLE_MANAGEMENT)) {
            $xtemplate->parse('main.article_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, ARTICLE_CATEGORY_MANAGEMENT)) {
            $xtemplate->parse('main.article_category_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, PROCEDURE_MANAGEMENT)) {
            $xtemplate->parse('main.procedure_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, FIELD_MANAGEMENT)) {
            $xtemplate->parse('main.field_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, UNIT_MANAGEMENT)) {
            $xtemplate->parse('main.unit_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, ITEM_MANAGEMENT)) {
            $xtemplate->parse('main.item_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, ITEM_CATEGORY_MANAGEMENT)) {
            $xtemplate->parse('main.item_category_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, ITEM_PROPERTY_MANAGEMENT)) {
            $xtemplate->parse('main.property_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, LOGO_CATEGORY_MANAGEMENT)) {
            $xtemplate->parse('main.logo_category_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, MENU_CATEGORY_MANAGEMENT)) {
            $xtemplate->parse('main.menu_category_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, USER_MANAGEMENT)) {
            $xtemplate->parse('main.user_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, CONFIGURATION_MANAGEMENT)) {
            $xtemplate->parse('main.configuration_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, CONTACT_MANAGEMENT)) {
            $xtemplate->parse('main.contact_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, SLIDESHOW_MANAGEMENT)) {
            $xtemplate->parse('main.slideshow_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, IMAGE_CATEGORY_MANAGEMENT)) {
            $xtemplate->parse('main.image_category_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, ORDER_MANAGEMENT)) {
            $xtemplate->parse('main.order_management');
        }
        if (Utility::checkPermission('view', $groupFunctions, VIDEO_MANAGEMENT)) {
            $xtemplate->parse('main.video_management');
        }
        
        $xtemplate->assign('SITENAME', $_SESSION['web_information']['siteName']);
        $xtemplate->assign('FULLNAME', $_SESSION['session']['sFullname']);
        
        $xtemplate->parse('main');
        $xtemplate->out('main');
    }

}
